#include "HUDplayerPosition.h"
#include "Transformation.h"
#include "Scene.h"
#include "PlainTexture.h"
#include "HUDplayerPosBehaviour.h"

using namespace game_engine;
using namespace game_engine::library;
using namespace game_engine::components;
using namespace game_engine::utils;

///////////////////////////////////////////////////////////////////////////////
// Constructors and Destructors
///////////////////////////////////////////////////////////////////////////////

HUDplayerPosition::HUDplayerPosition(void)
{
}

HUDplayerPosition::HUDplayerPosition(Scene *scn, const string &n, const string &t, 
    const DrawLevelType d)
    : GameObject(scn, n, t, d)
{
    // Create its components
    Transformation *transf = new Transformation(this, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0);
    PlainTexture *texture = new PlainTexture(this, string(), GL_RGBA, true);
    HUDplayerPosBehaviour *behaviour = new HUDplayerPosBehaviour(this);

    // Add components to object
    addComponent(transf);
    addComponent(texture);
    addComponent(behaviour);
}

HUDplayerPosition::~HUDplayerPosition(void)
{
}

///////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////

void HUDplayerPosition::setXPosition(const FLOAT32 xPos)
{
    // Get the Transformation component
    Transformation *transf = dynamic_cast<Transformation*> 
		(getComponent("Transformation"));
    transf->setXPosition(xPos);
}

void HUDplayerPosition::setYminPosition(const FLOAT32 yPos)
{
    // Get the HUDplayerPosBehaviour component
    HUDplayerPosBehaviour *behaviour = 
        dynamic_cast<HUDplayerPosBehaviour*> (getComponent("HUDplayerPosBehaviour"));
    behaviour->setIconYmin(yPos);
}

void HUDplayerPosition::setYmaxPosition(const FLOAT32 yPos)
{
    // Get the HUDplayerPosBehaviour component
    HUDplayerPosBehaviour *behaviour = 
        dynamic_cast<HUDplayerPosBehaviour*> (getComponent("HUDplayerPosBehaviour"));
    behaviour->setIconYmax(yPos);
}

void HUDplayerPosition::setTextureFile(const string &file)
{
    // Get the PlainTexture component
    PlainTexture *texture = dynamic_cast<PlainTexture*> (getComponent("PlainTexture"));
    texture->setTextureFile(file);
}

void HUDplayerPosition::setTextureType(const INT32 type)
{
    // Get the PlainTexture component
    PlainTexture *texture = dynamic_cast<PlainTexture*> (getComponent("PlainTexture"));
    texture->setTextureType(type);
}

void HUDplayerPosition::setSubject(GameObject *obj)
{
    // Get the HUDplayerPosBehaviour component
    HUDplayerPosBehaviour *behaviour = 
        dynamic_cast<HUDplayerPosBehaviour*> (getComponent("HUDplayerPosBehaviour"));
    behaviour->setSubject(obj);
}

